package com.maple.soa.dao;

import com.maple.soa.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

/**
 * @author lijian
 * @date 2020/7/6
 */
@Repository
public class UserDao {
    @Autowired
    private User user1;
    @Autowired
    @Qualifier("user2")
    private User user2;
    @Autowired
    @Qualifier("user3")
    private User user3;

    public User getById(Long id) {
        if (id == 1) {
            return user1;
        } else if (id == 2) {
            return user2;
        } else {
            return user3;
        }
    }

    public void saveOrUpdate(User user) {
        user1 = user;
    }

}
